<h2>Modify Book</h2>

<?php 

if(!session_id()) session_start(); 
$con = mysql_connect($dbserver, $dbuser, $dbpass);
if ($con)
{
	mysql_select_db($db, $con);
	

		$q = fquery($book_query, array($_GET['id']));
		$result = mysql_query($q);
		$book = mysql_fetch_array($result);
		mysql_close($con);
		
}
else{
	echo "<font color='red'> Error Connecting to DB!</font>";
}

?>

<form action='../actions/books/modify_book.php' method='POST' enctype="multipart/form-data">
<input hidden type='text' name='mediaID' value='<?php echo $book['media_id'] ?>'/>
<input hidden type='text' name='prev_cover_img' value='<?php echo $book['cover_image'] ?>'/>
	<table id = 'std_padding'>
		<tr>
			<td>Title: </td><td><input type='text' name='title' value='<?php echo $book['title'] ?>' /></td>
		</tr>
		<tr>
			<td>Edition: </td><td><input type="text" name="edition" value='<?php echo $book['edition'] ?>' /></td>
		</tr>
		<tr>
			<td>ISBN: </td><td><input type="text" name="isbn" value='<?php echo $book['isbn'] ?>' /></td>
		</tr>
		<tr>
			<td>Author(s): </td><td><input type="text" name="authors" value='<?php echo $book['authors'] ?>' /></td>
		</tr>
		<tr>
			<td>Publishing Year: </td><td><input type="text" name="year" value='<?php echo $book['publishing_year'] ?>' /></td>
		</tr>
		<tr>
			<td>Publisher: </td><td><input type="text" name="publisher" value='<?php echo $book['publisher'] ?>' /></td>
		</tr>
		<tr>
			<td>Number of Pages: </td><td><input type="text" name="no_of_pages" value='<?php echo $book['number_of_pages'] ?>' /></td>
		</tr>
		<tr>
			<td>Description: </td><td><input type="text" name="description" value='<?php echo $book['description'] ?>' /></td>
		</tr>
		<tr>
			<td>Location: </td><td><input type="text" name="location" value='<?php echo $book['location'] ?>' /></td>
		</tr>
		<tr>
			<td>Format: </td><td><input type="text" name="format" value='<?php echo $book['format'] ?>' /></td>
		</tr>
		<tr>
			<td>Dewey Decimal Number: </td><td><input type="text" name="dewey_decimal_number" value='<?php echo $book['dewey_decimal_number'] ?>' /></td>
		</tr>
		<tr>
			<td>Cover Image: </td><td><input type="file" accept="image/bmp, image/gif, image/jpeg, image/jpg, image/png" name="cover_image" /></td>
		</tr>
		<tr>
			<td id='bookimgContainer'> <img id='bookimg' src='<?php echo $book['cover_image'] ?>'/> </td>
			<td>&nbsp;<input type="submit" value="Update" /></td>
		</tr>
		<tr>
			<td></td>
			
		</tr>
	</table>
</form>